
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>编辑</title>
  <link rel="stylesheet" href="../../css/element.css">
	<link rel="stylesheet" href="../../css/common.css">
  <link rel="stylesheet" href="../../css/edit.css"> 
    
</head>

<body>
	<div id="app" v-cloak>
        <div id="mask" v-if="maskShow"></div>
        <div id="notice-mask" v-if="ifNoticeListShow">
          <div id="notice-wrap">
            <p class="item-title">选择公告原文</p>
            <el-table
              ref="singleTable"
              :data="noticeResult"
              stripe
              highlight-current-row
              @current-change="selectNotice"
              style="width: 100%"
              >
              
              
              <el-table-column
                width="1000"
                label="扣分内容">
                <template slot-scope="scope">
                  <a :href="scope.row.deal_content_url" class="table-link" target="blank">{{ scope.row.deal_content }}</a>
                </template>
              </el-table-column>
              <el-table-column
                prop="deal_time"
                label="日期">
              </el-table-column>
            </el-table>

            <p style="text-align: center;">
              <el-button type="primary" @click="ifNoticeListShow=false">确定</el-button>
            </p>
          </div>
        </div>
        <el-container style="height: 100%;">


          <el-header>
            <div class="layout-logo">
                <img src="../../images/logo.png" alt="">
            </div>
            <!-- <div class="head-nav">
              <a href="javascript:void(0)" class="active">合规审核</a>
              <a href="../dataquery/complex.html">数据查询</a>
            </div> -->
            <div class="layout-nav font12 user_msg">
                欢迎您，{{userName}}  <a class="red" href="javascript:void(0)" @click="userQuit"> 注销 </a>
            </div>
          </el-header>

          <el-container>
           
            <!-- 右侧主视图部分 BEGIN  -->
            <el-container>

              <!-- content container begin -->
              <el-main>
                <el-card class="main-card">
  
                  <div slot="header" class="clearfix">
                    <span class="font12 gray">当前位置：编辑</span>
                  </div>

                  <div class="clearfix main-wrap" style="height:100%;">
                    <div class="fl" style="width:50%;height:100%;">
                      
                      <p class="item-title">修改</p>

                      <div class="item-wrap">
                        <span class="input-label">
                          <dd>证券代码：</dd>
                        <el-input size="small" v-model="secu_code" disabled></el-input></span>
                      </div>

                      <div class="item-wrap col-2">
                        <span class="input-label">
                          <dd>公司简称：</dd>
                          <el-input size="small" v-model="company_name" disabled></el-input>
                        </span>
                        <span class="input-label">
                          <dd>扣分类型：</dd>
                          <el-select size="small" v-model="formVal.deal_type">
                            <el-option v-for="item in deTypeArr" :label="item" :value="item"></el-option>
                          </el-select>
                        </span>
                      </div>

                      <div class="item-wrap col-2">
                        <span class="input-label">
                          <dd>扣分内容：</dd>
                          <el-input size="small" v-model="formVal.deal_content"></el-input>
                        </span>

                        <span class="input-label">
                          <dd class="long">公告日期：</dd>
                          <el-date-picker v-model="formVal.deal_time" type="date" placeholder="选择日期" size="small" value-format="yyyy-MM-dd"></el-date-picker>
                        </span>
                      </div>

                      <div class="item-wrap">
                        <span class="input-label">
                          <dd>扣分值：</dd>
                          <el-input size="small" max=0 min=-100 type="number" v-model="formVal.deal_score"></el-input>
                        </span>
                      </div>

                      <div class="item-wrap">
                        <span class="input-label">
                          <dd>选择状态：</dd>
                          <el-select size="small" v-model="formVal.audit_state">
                            <el-option v-for="item in selectOptions" :label="item.label" :value="item.value"></el-option>
                          </el-select>
                        </span>
                      </div>

                     

                      
                      <div class="item-wrap">

                        <span class="input-label">
                          <dd>备注：</dd>
                          <el-input size="small"  type="textarea" v-model="formVal.note"></el-input>
                        </span>
                      </div>

                      <div class="item-wrap bottom-button">
                        <el-button type="primary" @click="submitForm">确定</el-button>
                        <el-button type="info" @click="cancelForm">取消</el-button>
                      </div>
                    </div>

                    <div class="fl" style="width:50%;height:100%;">
                      <p class="query-title">
                        请输入要查询的公司代码:
                        <el-input size="small" v-model="querySecuCode"></el-input>
                        <el-button size="small" type="primary" @click="getQuery(querySecuCode)">查询</el-button>
                      </p>

                      <div class="table-wrap">
                        <el-table
                        :data="queryResult"
                        v-loading="loading"
                        border
                        stripe
                        style="width: 100%"
                        empty-text="该公司暂无扣分项"
                        >
                        
                        <el-table-column
                          prop="deal_time"
                          label="日期">
                        </el-table-column>
                        <el-table-column
                          prop="deal_type"
                          label="扣分类型">
                        </el-table-column>
                        <el-table-column
                          label="扣分内容">
                          <template slot-scope="scope">
                            <a :href="scope.row.deal_content_url" class="table-link" target="blank">{{ scope.row.deal_content }}</a>
                          </template>
                        </el-table-column>
                        <el-table-column
                          prop="deal_score"
                          label="扣分值">
                        </el-table-column>

                      </el-table>
                      </div>
                    </div>
                  </div>
  
                </el-card>
              </el-main>
              <!-- content container end -->


              <el-footer>
                  <p class="gray">
                    @中国财富传媒集团 版权所有
                  </p>
              </el-footer>

            </el-container>
            <!-- 右侧主视图部分 END  -->
          </el-container>

        </el-container>
    </div>
</body>
    <script src="../../js/vue.js"></script>
    <script src="../../js/element.js"></script>
    <script src="../../js/axios.min.js"></script>
    <script src="../../js/common.js"></script>
  	<script>
  	  var app = new Vue({
  	      el: '#app',
          data(){
            return{
              maskShow:false,
              userName:localStorage.sys_userName,
              deTypeArr:[],
              querySecuCode:'',
              int_date:'',
              loading:false,
              ifNoticeListShow:false,
              queryResult:[],
              noticeResult:[],
              ifAvailable:false,
              selectOptions: [
                {
                  value: '全部',
                  label: '全部'
                }, {
                  value: '未审核',
                  label: '未审核'
                }, {
                  value: '审核通过',
                  label: '审核通过'
                }, {
                  value: '已修改',
                  label: '已修改'
                }, {
                  value: '已删除',
                  label: '已删除'
                } 
              ],
              secu_code:'',
              company_name:'',
              formVal:{
                id:window.GetQueryString('itemId')?window.GetQueryString('itemId'):'',
                login_name:localStorage.sys_userName,
                deal_type:'',
                deal_content:'',
                deal_score:0,
                audit_state:'已修改',
                deal_time:'',
                note:''
                
              },
              myHead:{
                
              }
            }
              
          },
          mounted:function(){
              this.initPage();
          },
          methods:{
            userQuit:function(){
              this.$confirm('确认退出当前账户？', '确认退出', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
              }).then(()=>{
                    Common.quit();
              }).catch(()=>{
                return false;
              });


            },
            initPage:function(){

              // 获取扣分类型
              axios
              .get(`https://goldeye.cfbond.com/cmsys/deal_type?session_id=${localStorage.sys_sessionId}`)
              .then((res)=>{
                if(res.data.flag){
                  this.deTypeArr = res.data.data;
                  this.deTypeSel = this.deTypeArr[0];
                }else{

                }
                
              }); 
              var _id = window.GetQueryString('itemId')?window.GetQueryString('itemId'):'';
              console.log(_id.length);
              if(_id.length){
                axios
                .get(`https://goldeye.cfbond.com/cmsys/compliance_audit_query?session_id=${localStorage.sys_sessionId}`,{
                  params:{
                    id:_id
                  }
                })
                .then((res)=>{
                  console.log(res);
                  if(res.data.flag){
                    this.secu_code = res.data.data.secu_code;
                    this.company_name = res.data.data.company_name;
                    this.formVal.deal_time = res.data.data.deal_time;
                    this.formVal.deal_type = res.data.data.deal_type;
                    this.formVal.note = res.data.data.note;
                    this.formVal.deal_score = res.data.data.deal_score;
                    this.formVal.deal_content = res.data.data.deal_content;
                    this.formVal.deal_time = this.getFormatDate(new Date());
                    this.querySecuCode = res.data.data.secu_code;
                    this.getQuery(this.querySecuCode);
                  }else{

                  }
                  
                });
              }else{
                window.location.href="./add.html";
              }           
            },
            getQuery:function(sCode){
              if(sCode.length!=6){
                this.$message.error('错误的证券代码');
              }else{
                this.loading = true;
                axios
                .get('https://goldeye.cfbond.com/cmsys/compliance_audit_list',{
                  params:{
                    secu_code:sCode,
                    page_size:1000,
                    audit_state:'全部',
                    api_type:'add',
                    session_id:localStorage.sys_sessionId
                  }
                })
                .then((res)=>{
                  if(res.data.flag){
                    this.queryResult = res.data.data.data_list;
                  }
                  this.loading = false;
                });
              }
              
            },
            chooseNotice:function(){
              if(this.formVal.secu_code.length!=6){
                this.$message.error('请先输入正确的证券代码！');
              }else{
                axios
                .get('https://goldeye.cfbond.com/cmsys/compliance_audit_list',{
                  params:{
                    secu_code:this.formVal.secu_code,
                    page_size:1000,
                    audit_state:'全部',
                    session_id:localStorage.sys_sessionId
                  }
                })
                .then((res)=>{
                  if(res.data.flag){
                    this.noticeResult = res.data.data.data_list;
                    this.ifNoticeListShow = true;
                  }
                });
              }
            },
            selectNotice:function(val){
              if(val){
                console.log(val);
                this.formVal.deal_time = val.deal_time;
                this.formVal.deal_title= val.deal_content;
                this.formVal.deal_url= val.deal_content_url;
                this.ifAvailable = true;
                // this.ifNoticeListShow = false;
              }else{}
            },
            submitForm:function(){
              if(this.formVal.secu_code==''||this.formVal.company_name==''||this.formVal.deal_type==''||this.formVal.deal_content==''||this.formVal.audit_state==''){
                this.$message.error('除备注外，其余每项均为必填项，请以上完善信息');
              }else{
                axios
                .get(`https://goldeye.cfbond.com/cmsys/compliance_audit_update?session_id=${localStorage.sys_sessionId}`,{
                  params:this.formVal
                })
                .then((res)=>{
                  if(res.data.flag){
                    this.$alert('修改成功', '成功', {
                      confirmButtonText: '确定',
                      callback: action => {
                        window.location.href="./audit.html";
                      }
                    });
                  }
                });
              }
            },
            cancelForm:function(){
              this.$confirm('确定退出编辑，返回列表页?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
              }).then(() => {
                window.location.href="./audit.html";
              }).catch(() => {
                        
              });
            },
            upLoadSuccess:function(res){//上传成功
              console.log(res);
            },
            upLoadFailed:function(err){//上传失败
              console.log(err);
            },
            getFormatDate:function(_obj){
              console.log(_obj);
              let oY = _obj.getFullYear().toString();
              let oM = ( _obj.getMonth() + 1 ).toString().length>1?(_obj.getMonth()+1).toString():'0'+(_obj.getMonth()+1).toString();
              let oD = _obj.getDate().toString().length>1?_obj.getDate().toString():'0'+_obj.getDate().toString();
              return `${oY}-${oM}-${oD}`;
            }

          }
  	  });
  	</script>

</html>